// 足迹因子匹配规则
import { get, post } from '@/utils/http';
import {
  IGetFactorMatchListReq,
  IGetFactorMatchListRes,
  IGetUnconfirmedRuleListReq,
  IGetUnconfirmedRuleListRes,
  IHandleBatchType
} from './model/factorMatchingRule';
enum Api {
  // 足迹因子匹配规则列表分页查询
  GET_MATCH_RULE = '/datamatch/rule/pageMatchRule',
  // 待确认规则
  GET_UNCONFIRMED_RULE = '/datamatch/flowMatchRule/page',
  // 批量生成规则
  BATCH_GENERATE = '/datamatch/flowMatchRule/generate',
  // 批量忽略规则
  BATCH_IGNORE = '/datamatch/flowMatchRule/ignore',
  // 批量移除忽略规则
  BATCH_REMOVE_IGNORE = '/datamatch/flowMatchRule/removeIgnore',
  // 查询待确认规则条数
  QUERY_UNCONFIRMED_RULE_NUM = '/datamatch/flowMatchRule/queryWaitConfirmNum',
  // 删除规则
  REMOVE_RULE = '/datamatch/rule/removeRule',
  // 编辑规则
  UPDATE_RULE = '/datamatch/rule/updateRule',
  // 新增规则
  CREATE_RULE = '/datamatch/rule/createRule'
}
// 足迹因子匹配规则列表分页查询
export const getMatchRuleList = (
  params: IGetFactorMatchListReq
): Promise<IGetFactorMatchListRes[]> => get(Api.GET_MATCH_RULE, params);
// 待确认规则
export const getUnconfirmedRuleList = (
  params: IGetUnconfirmedRuleListReq
): Promise<IGetUnconfirmedRuleListRes[]> => get(Api.GET_UNCONFIRMED_RULE, params);
// 批量生成规则
export const batchGenerate = (params: IHandleBatchType) => post(Api.BATCH_GENERATE, params);
// 批量忽略规则
export const batchIgnore = (params: IHandleBatchType) => post(Api.BATCH_IGNORE, params);
// 批量移除忽略规则
export const batchRemoveIgnore = (params: IHandleBatchType) =>
  post(Api.BATCH_REMOVE_IGNORE, params);
// 查询待确认规则条数
export const queryUnConfirmedRuleNum = () => get(Api.QUERY_UNCONFIRMED_RULE_NUM, {});
// 删除规则
export const removeRule = (param: { ruleNos: string[] }) => post(Api.REMOVE_RULE, param);
// 编辑规则
export const updateRule = (param: { ruleNo: string; factorNo: string }) =>
  post(Api.UPDATE_RULE, param);
// 新增规则
export const addRule = (param: {
  category: string;
  applicableStandard: string[];
  keyName: string;
  factorNo: string;
}) => post(Api.CREATE_RULE, param);
